package flc.ast.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.DrawTempAdapter;
import flc.ast.bean.DrawTempBean;
import flc.ast.databinding.ActivityDrawTempBinding;

public class DrawTempActivity extends BaseAc<ActivityDrawTempBinding> {

    public static int type;
    private DrawTempAdapter tempAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_draw_temp;
    }

    @Override
    protected void initView() {
        mDataBinding.ivDrawTempBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.rvDrawTempList.setLayoutManager(new GridLayoutManager(mContext, 2));
        tempAdapter = new DrawTempAdapter();
        mDataBinding.rvDrawTempList.setAdapter(tempAdapter);
        tempAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        DrawActivity.kind = 0;
        DrawActivity.selImg = tempAdapter.getItem(position).getDrawImg();
        startActivity(DrawActivity.class);
    }

    @Override
    protected void initData() {
        if (type == 0) {
            mDataBinding.tvDrawTempTitle.setText(getString(R.string.template_name1));
            setData1();
        } else if (type == 1) {
            mDataBinding.tvDrawTempTitle.setText(getString(R.string.template_name2));
            setData2();
        } else if (type == 2) {
            mDataBinding.tvDrawTempTitle.setText(getString(R.string.template_name3));
            setData3();
        }
    }

    private void setData1() {
        List<DrawTempBean> list = new ArrayList<>();
        list.add(new DrawTempBean(R.drawable.m1, R.drawable.mb1));
        list.add(new DrawTempBean(R.drawable.m2, R.drawable.mb2));
        list.add(new DrawTempBean(R.drawable.m3, R.drawable.mb3));
        list.add(new DrawTempBean(R.drawable.m4, R.drawable.mb4));
        list.add(new DrawTempBean(R.drawable.m5, R.drawable.mb5));
        list.add(new DrawTempBean(R.drawable.m6, R.drawable.mb6));
        list.add(new DrawTempBean(R.drawable.m7, R.drawable.mb7));
        list.add(new DrawTempBean(R.drawable.m8, R.drawable.mb8));
        tempAdapter.setList(list);
    }

    private void setData2() {
        List<DrawTempBean> list = new ArrayList<>();
        list.add(new DrawTempBean(R.drawable.m9, R.drawable.mb9));
        list.add(new DrawTempBean(R.drawable.m10, R.drawable.mb10));
        list.add(new DrawTempBean(R.drawable.m11, R.drawable.mb11));
        list.add(new DrawTempBean(R.drawable.m12, R.drawable.mb12));
        list.add(new DrawTempBean(R.drawable.m13, R.drawable.mb13));
        list.add(new DrawTempBean(R.drawable.m14, R.drawable.mb14));
        list.add(new DrawTempBean(R.drawable.m15, R.drawable.mb15));
        list.add(new DrawTempBean(R.drawable.m16, R.drawable.mb16));
        tempAdapter.setList(list);
    }

    private void setData3() {
        List<DrawTempBean> list = new ArrayList<>();
        list.add(new DrawTempBean(R.drawable.m17, R.drawable.mb17));
        list.add(new DrawTempBean(R.drawable.m18, R.drawable.mb18));
        list.add(new DrawTempBean(R.drawable.m19, R.drawable.mb19));
        list.add(new DrawTempBean(R.drawable.m20, R.drawable.mb20));
        list.add(new DrawTempBean(R.drawable.m21, R.drawable.mb21));
        list.add(new DrawTempBean(R.drawable.m22, R.drawable.mb22));
        list.add(new DrawTempBean(R.drawable.m23, R.drawable.mb23));
        list.add(new DrawTempBean(R.drawable.m24, R.drawable.mb24));
        tempAdapter.setList(list);
    }

}